package com.common.handler.impl;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.common.groovy.adapter.GroovyModelAdapter;
import com.common.handler.HttpMethodHandler;
import com.common.model.SystemApplicationServiceModel;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Description:
 * @Date: 2025/7/3 22:19
 */
@Component
public class HttpGetMethodHandler extends HttpMethodHandler<JSONObject> {

    @Override
    public boolean validateMethod(String method) {
        return HttpMethod.GET.toString().equals(method);
    }

    @Override
    public JSONObject parseParams(ServletRequest servletRequest, ServletResponse servletResponse) {
        JSONObject params = JSONUtil.createObj();
        for (Map.Entry<String, String[]> paramEntrySet : servletRequest.getParameterMap().entrySet()) {
            params.set(paramEntrySet.getKey(), paramEntrySet.getValue()[0]);
        }
        return params;
    }


}
